#!/usr/bin/python

import zipfile
import os

 
class ZipUtilities:
	
	def __init__(self, filename):
		self.zip_file = zipfile.ZipFile(filename + '.zip', 'w') 

	def add(self, file): 
	
		if os.path.isfile(file):
			self.zip_file.write(file)
		else:
			self.addFolderToZip(file)
		

	def addFolderToZip(self,folder):
		for file in os.listdir(folder):
			self.full_path = os.path.join(folder, file)
			if os.path.isfile(self.full_path):
				print 'File added: ' + str(self.full_path)
				self.zip_file.write(self.full_path)
			elif os.path.isdir(self.full_path):
				print 'Entering folder: ' + str(self.full_path)
				self.addFolderToZip(self.zip_file, self.full_path)
	
	def close(self):
		self.zip_file.close();

if __name__ == "__main__":

	a = ZipUtilities('Myzip')
	a.add('/home/juan/Documents/Maggie/Ginastera TESIS/Bomarzo.doc')
	a.add('/home/juan/Documents/Maggie/Ginastera TESIS/bibliografia.doc')
	a.close()
